#!/bin/bash

ECHO="echo -e"
CURDIR=`pwd`
configfile=$CURDIR/../conf/config/remoteServers
if [ ! -f $configfile ]; then
    $ECHO "$configfile must exist."
    exit
fi

CURDIR=`pwd`
if [ -n "$1" ]; then
    remotes=$1
else
    remotes=`cat $CURDIR/config/remoteServers`
fi

for i in $remotes; 
do
    $ECHO "\ndo with $i"
    expect -c "set timeout 60;
              spawn ssh-copy-id $i;
              expect {
                  *assword:* { send rmt123\r; }
              }
              interact;"
done

$ECHO "\n\t Everything done.\n"

